package com.example.mapper.institutioncare.fuwuxinxi;

import com.example.bean.configuration.zhibiaosystem.XzLiebiao;
import com.example.bean.institutioncare.fuwuxinxi.FuWuXinXi;
import com.example.bean.institutioncare.fuwuxinxi.FuWuXinXiVo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
@Mapper
@Repository
public interface FuWuXinXiMapper {
    List pagefuwuxinxi(FuWuXinXiVo fuWuXinXiVo);

    Integer addFuWuXinXi(FuWuXinXi fuWuXinXi);

    @Select("select xz_liebiao.* from xz_liebiao left join zhibiao on xz_liebiao.zb_id=zhibiao.noid where zhibiao.zbx_name='机构提供的服务内容：'")
    List<XzLiebiao> listzhibiao();

    @Select("select fuwuxinxi.noid from fuwuxinxi where niandu = #{niandu} and yachang = #{yachang}")
    String chafuwu(FuWuXinXi fuWuXinXi);

    @Insert("insert into fuwuxinxi_zhibiao(noid,fuwuzhiliang_id,zhibiaozhi_id) values(replace(uuid(),'-',''),#{fuwuzhiliangId},#{zhibiaozhiId})")
    void addzhongjian(@Param("fuwuzhiliangId") String noid, @Param("zhibiaozhiId") String noid1);

    @Select("select * from fuwuxinxi where noid = #{noid}")
    FuWuXinXi huixianfuwuxinxi(String noid);

    @Select("select zhibiaozhi_id from fuwuxinxi_zhibiao where fuwuzhiliang_id = #{noid}")
    ArrayList<String> huixianzhongjian(String noid);

    @Update("update fuwuxinxi set jigou_id = #{jigouId},niandu = #{niandu},ruyuanpinggu = #{ruyuanpinggu},wenhuayule = #{wenhuayule},shipu = #{shipu},yachang = #{yachang},jinxingtijian = #{jinxingtijian},tijianrenshu = #{tijianrenshu},canyintijian = #{canyintijian},canyinrenshu = #{canyinrenshu},yiliaoshigu = #{yiliaoshigu},shiwuzhongdu = #{shiwuzhongdu},zerenshigu = #{zerenshigu},tousu = #{tousu},guanlibumen = #{guanlibumen},guanlizhidu = #{guanlizhidu},waibupingjia = #{waibupingjia},huliyuan = #{huliyuan},fuwupingbi = #{fuwupingbi},goutongjizhi = #{goutongjizhi},fuzetousu = #{fuzetousu},wudingqi = #{wudingqi},huoweihui = #{huoweihui},manyidudiaocha = #{manyidudiaocha},manyiduniandu = #{manyiduniandu},qinshu = #{qinshu},ganran = #{ganran},is_delete = 1 where noid = #{noid}")
    Integer xiugaifuwu(FuWuXinXi fuWuXinXi);

    //删除中间表的信息
    @Delete("delete from fuwuxinxi_zhibiao where fuwuzhiliang_id = #{fuwuzhiliangId}")
    Integer shanfuwu(String noid);

    Integer piliangshan(List<String> ids);
}
